/********************************************
*	Simple objects
*********************************************/
//create a new object
var obj = new Object(); 

//create a new property color
obj.color = 0xffffff; //hex number ~> 16777215
obj.items = new Array(1,2,3,4); //array of numbers
obj.click = function(){
	//we can access the color property
	console.debug(this.color);
}
//call click method
obj.click();

//creates a new object
var obj = {
	//creates property color
	color: 0xffffff,
	//array of numbers
	items: [1,2,3,4],
	//this method belongs to the obj object
	click: function(){
		//we can access the color property
		console.debug(this.color);
	}
}
//call click method
obj.click();

/********************************************
*	Creating instances
*********************************************/

//A simple function (Object)
function Person(name,lastName){
	//save the name and last name in the current context
	this.name = name;
	this.lastName = lastName;
}

//Instance the function Person
var john = new Person("John","Doe");
//print the name property
console.debug(john.name+" "+john.lastName);
//it is an instance of the Person Object
console.debug(john.constructor == Person);

/********************************************
*	Creating public methods
*********************************************/
//Animal object
var Animal = function(name){
	this.name = name;
}
//add a public method to the Animal object
Animal.prototype.getName = function(){
	//the context is going to be within the instantiated object
	return this.name;
}
//add a public method
Animal.prototype.setName = function(name){
	//change the value of the name property
	this.name = name;
}

//create a dog and cat instances
var dog = new Animal("Lucky");
var cat = new Animal("Milo");

//calling the getName method
console.debug(dog.getName());
console.debug(cat.getName());